package com.njwb.day15.zqzb.job.Test01;

import java.util.HashMap;
import java.util.Map;

import static com.njwb.day15.zqzb.job.Test01.read.phones;

public class sumcost {
    public static Map<String, cost> costs = new HashMap<>();

    public static void suncost() {
        int sum=0;
        for (Phone phone : phones) {
            String caller = phone.getCaller();
            int type = phone.getType();
            int time = phone.getTime();
switch (type){
    case 1:
        sum=1*time;break;
    case 2:
        sum=2*time;break;
    case 3:
        sum=10*time;break;
}

            int existingCost = costs.containsKey(caller) ? costs.get(caller).getCost() : 0;
            costs.put(caller, new cost(caller, existingCost + sum));
        }
    }
}